#!/usr/bin/python3
# _*_ coding:utf-8 _*_

import os


def get_file_size(path):
    size = 0
    if os.path.isfile(path):
        size += os.path.getsize(path)
    
    for item in os.listdir(path):
        next_path = os.path.join(path, item)
        if os.path.isfile(next_path):
            size += os.path.getsize(next_path)
        else:
            size += get_file_size(next_path)
    return size


if __name__ == "__main__":
    path1 = r"/home/chair/projects/code0"
    result = get_file_size(path1)
    print(result)
